package com.ruoyi.statisticalCenter.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.domain.vo.InitTableVo;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.common.service.TableService;
import com.ruoyi.common.utils.GetDateStringUtils;
import com.ruoyi.hqfinance.domain.HqNetworkBillDetail;
import com.ruoyi.hqfinance.mapper.HqNetworkBillDetailMapper;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.PageInfo;
import com.ruoyi.logistic.domain.ScQualityControlFeeSheetCache;
import com.ruoyi.logistic.mapper.ScQualityControlFeeSheetCacheMapper;
import com.ruoyi.statisticalCenter.domain.ScQualityControlDisposition;
import com.ruoyi.statisticalCenter.domain.ScQualityControlFeeSheet;
import com.ruoyi.statisticalCenter.domain.vo.DateStrVo;
import com.ruoyi.statisticalCenter.domain.vo.ScQualityControlDispositionVo;
import com.ruoyi.statisticalCenter.domain.vo.ScQualityControlFeeSheetPointVo;
import com.ruoyi.statisticalCenter.domain.vo.ScQualityControlFeeSheetVo;
import com.ruoyi.statisticalCenter.mapper.ScQualityControlDispositionMapper;
import com.ruoyi.statisticalCenter.mapper.ScQualityControlFeeSheetMapper;
import com.ruoyi.statisticalCenter.service.ScQualityControlFeeSheetService;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ScQualityControlFeeSheetServiceImpl implements ScQualityControlFeeSheetService {
    @Autowired
    private ScQualityControlFeeSheetMapper scQualityControlFeeSheetMapper;
    @Autowired
    private TableService tableService;
    @Autowired
    private ScQualityControlDispositionMapper scQualityControlDispositionMapper;
    @Autowired
    private HqNetworkBillDetailMapper hqNetworkBillDetailMapper;
    @Autowired
    private ScQualityControlFeeSheetCacheMapper scQualityControlFeeSheetCacheMapper;

    private BigDecimal systemServiceCharge, wovenBagsCharge = new BigDecimal(0);

    @Override
    public R cache(DateStrVo dateStrVo) {
        List<String> times = GetDateStringUtils.generateDatesForMonth(2024, 6);
        Integer[] networkLevels = {0, 1, 2};

        List<String> days = GetDateStringUtils.getDateStr(dateStrVo.getStartDateStr(), dateStrVo.getEndDateStr());
        List<String> dateStrList = scQualityControlFeeSheetCacheMapper.selectllDateStr();
        days.removeAll(dateStrList);

        for (String day : days) {
            //String day = time;
            for (Integer networkLevel : networkLevels) {
                ScQualityControlFeeSheetVo vo = new ScQualityControlFeeSheetVo();
                vo.setStartTime(day);
                vo.setEndTime(day);
                vo.setNetworkLevel(networkLevel);
                List<ScQualityControlFeeSheet> collect = scQualityControlFeeSheetMapper.collect(vo);
                //获取网点系统服务费、编织袋应收
                if (networkLevel == 0) {
                    for (ScQualityControlFeeSheet scQualityControlFeeSheet : collect) {
                        systemServiceCharge = scQualityControlFeeSheet.getSystemServiceCharge();
                        wovenBagsCharge = scQualityControlFeeSheet.getWovenBagsCharge();
                    }
                }
                //细分到承包区
                else if (networkLevel == 1 || networkLevel == 2) {
                    int tickets = 0;
                    for (ScQualityControlFeeSheet scQualityControlFeeSheet : collect) {
                        if (!scQualityControlFeeSheet.getName().equals("辽宁盘锦公司")) {
                            tickets += scQualityControlFeeSheet.getInboundTickets() + scQualityControlFeeSheet.getInboundTickets();
                        }
                    }
                    if (tickets != 0) {
                        for (ScQualityControlFeeSheet scQualityControlFeeSheet : collect) {
                            if (scQualityControlFeeSheet.getName().equals("辽宁盘锦公司")) {
                                scQualityControlFeeSheet.setSystemServiceCharge(new BigDecimal(0));
                                scQualityControlFeeSheet.setWovenBagsCharge(new BigDecimal(0));
                            } else {
                                int sheetTickets = scQualityControlFeeSheet.getInboundTickets() + scQualityControlFeeSheet.getInboundTickets();
                                scQualityControlFeeSheet.setSystemServiceCharge(systemServiceCharge.divide(new BigDecimal(tickets),5,BigDecimal.ROUND_UP).multiply(new BigDecimal(sheetTickets)).setScale(3,RoundingMode.HALF_UP));
                                scQualityControlFeeSheet.setWovenBagsCharge(wovenBagsCharge.divide(new BigDecimal(tickets),5,BigDecimal.ROUND_UP).multiply(new BigDecimal(sheetTickets)).setScale(3,RoundingMode.HALF_UP));
                            }
                        }
                    }
                }
                List<ScQualityControlFeeSheetCache> list = new ArrayList<>();
                for (ScQualityControlFeeSheet sheet : collect) {
                    ScQualityControlFeeSheetCache cache = new ScQualityControlFeeSheetCache();
                    BeanUtils.copyProperties(sheet, cache);
                    cache.setDeductPayDate(day);
                    cache.setNetworkLevel(networkLevel);
                    scQualityControlFeeSheetCacheMapper.insert(cache);
                    System.out.println("当前参数:time=" + day + ";networkLevel=" + networkLevel);
                    list.add(cache);
                }
//                System.out.println("当前参数:time="+day+";networkLevel="+networkLevel);
                //scQualityControlFeeSheetCacheMapper.insertList(list);
            }
        }
        return R.ok();
    }

    @Override
    public R collect(ScQualityControlFeeSheetVo vo) {
        List<ScQualityControlFeeSheet> collect = collectList(vo);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", PageInfo.info(collect));
        jsonObject.put("fields", getTableVo());

        if (collect == null || collect.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(jsonObject);
        }
    }

    @Override
    public List<ScQualityControlFeeSheet> collectList(ScQualityControlFeeSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<ScQualityControlFeeSheet> collect = scQualityControlFeeSheetCacheMapper.selectScQualityControlFeeSheet(vo);
        if (collect == null || collect.size() == 0) {
            PageHelper.startPage(vo.getPageDate());
            if (vo.getNetworkLevel() == 3 || vo.getNetworkLevel() == 4) {
                ScQualityControlFeeSheetVo copyVo = new ScQualityControlFeeSheetVo();
                BeanUtils.copyProperties(vo, copyVo);
                copyVo.setNetworkLevel(vo.getNetworkLevel() == 3 ? 1 : 2);
                collect = this.collectList(copyVo);
                //落实明细查询

                List<ScQualityControlFeeSheet> collectSet = scQualityControlFeeSheetMapper.selectSetCollect(vo);

                ScQualityControlFeeSheet sheetSum = new ScQualityControlFeeSheet();
                sheetSum.setName("辽宁盘锦公司");
                for (ScQualityControlFeeSheet sheet : collectSet) {
                    sheetSum.setInboundTickets(sheetSum.getInboundTickets() + sheet.getInboundTickets());
                    sheetSum.setOutboundTickets(sheetSum.getOutboundTickets() + sheet.getOutboundTickets());
                    sheetSum.setOutboundThreePiecesDelay(sheetSum.getOutboundThreePiecesDelay().add(sheet.getOutboundThreePiecesDelay()));


                    sheetSum.setOutboundThreePiecesLost(sheetSum.getOutboundThreePiecesLost().add(sheet.getOutboundThreePiecesLost()));
                    sheetSum.setOutboundThreePiecesDamaged(sheetSum.getOutboundThreePiecesDamaged().add(sheet.getOutboundThreePiecesDamaged()));
                    sheetSum.setOutboundThreeReturnMoney(sheetSum.getOutboundThreeReturnMoney().add(sheet.getOutboundThreeReturnMoney()));
                    sheetSum.setOutboundThreePiecesTotal(sheetSum.getOutboundThreePiecesTotal().add(sheet.getOutboundThreePiecesTotal()));
                    sheetSum.setOutboundThreePiecesSingleReceipt(sheetSum.getOutboundThreePiecesSingleReceipt().add(sheet.getOutboundThreePiecesSingleReceipt()));
                    sheetSum.setToContractAreaDelay(sheetSum.getToContractAreaDelay().add(sheet.getToContractAreaDelay()));
                    sheetSum.setToContractAreaLost(sheetSum.getToContractAreaLost().add(sheet.getToContractAreaLost()));
                    sheetSum.setToContractAreaDamaged(sheetSum.getToContractAreaDamaged().add(sheet.getToContractAreaDamaged()));
                    sheetSum.setToContractAreaThreeReturnMoney(sheetSum.getToContractAreaThreeReturnMoney().add(sheet.getToContractAreaThreeReturnMoney()));
                    sheetSum.setToContractAreaTotal(sheetSum.getToContractAreaTotal().add(sheet.getToContractAreaTotal()));
                    sheetSum.setToContractAreaSingleReceipt(sheetSum.getToContractAreaSingleReceipt().add(sheet.getToContractAreaSingleReceipt()));
                    sheetSum.setToContractAreaProfitLoss(sheetSum.getToContractAreaProfitLoss().add(sheet.getToContractAreaProfitLoss()));
                    sheetSum.setInboundThreePiecesPenaltyDelay(sheetSum.getInboundThreePiecesPenaltyDelay().add(sheet.getInboundThreePiecesPenaltyDelay()));
                    sheetSum.setInboundThreePiecesPenaltyLost(sheetSum.getInboundThreePiecesPenaltyLost().add(sheet.getInboundThreePiecesPenaltyLost()));
                    sheetSum.setInboundThreePiecesPenaltyDamaged(sheetSum.getInboundThreePiecesPenaltyDamaged().add(sheet.getInboundThreePiecesPenaltyDamaged()));
                    sheetSum.setInboundThreePiecesPenaltyOverDispatchFee(sheetSum.getInboundThreePiecesPenaltyOverDispatchFee().add(sheet.getInboundThreePiecesPenaltyOverDispatchFee()));
                    sheetSum.setInboundThreePiecesThreeIndemnity(sheetSum.getInboundThreePiecesThreeIndemnity().add(sheet.getInboundThreePiecesThreeIndemnity()));
                    sheetSum.setInboundThreePiecesPenaltyTotal(sheetSum.getInboundThreePiecesPenaltyTotal().add(sheet.getInboundThreePiecesPenaltyTotal()));
                    sheetSum.setInboundThreePiecesPenaltyFinePerTicket(sheetSum.getInboundThreePiecesPenaltyFinePerTicket().add(sheet.getInboundThreePiecesPenaltyFinePerTicket()));
                    sheetSum.setPenaltyToContractAreaDelay(sheetSum.getPenaltyToContractAreaDelay().add(sheet.getPenaltyToContractAreaDelay()));
                    sheetSum.setPenaltyToContractAreaLost(sheetSum.getPenaltyToContractAreaLost().add(sheet.getPenaltyToContractAreaLost()));
                    sheetSum.setPenaltyToContractAreaDamaged(sheetSum.getPenaltyToContractAreaDamaged().add(sheet.getPenaltyToContractAreaDamaged()));
                    sheetSum.setPenaltyToContractAreaOverDispatchFee(sheetSum.getPenaltyToContractAreaOverDispatchFee().add(sheet.getPenaltyToContractAreaOverDispatchFee()));
                    sheetSum.setPenaltyToContractAreaThreeIndemnity(sheetSum.getPenaltyToContractAreaThreeIndemnity().add(sheet.getPenaltyToContractAreaThreeIndemnity()));
                    sheetSum.setPenaltyToContractAreaTotal(sheetSum.getPenaltyToContractAreaTotal().add(sheet.getPenaltyToContractAreaTotal()));
                    sheetSum.setPenaltyToContractAreaFinePerTicket(sheetSum.getPenaltyToContractAreaFinePerTicket().add(sheet.getPenaltyToContractAreaFinePerTicket()));
                    sheetSum.setThreeIndemnity(sheetSum.getThreeIndemnity().add(sheet.getThreeIndemnity()));
                    sheetSum.setPriorClaim(sheetSum.getPriorClaim().add(sheetSum.getPriorClaim()));
                    sheetSum.setFalseIssueAssessment(sheetSum.getFalseIssueAssessment().add(sheet.getFalseIssueAssessment()));
                    sheetSum.setFalseSignatureAssessment(sheetSum.getFalseSignatureAssessment().add(sheet.getFalseSignatureAssessment()));
                    sheetSum.setInadequateSignatureRateAssessment(sheetSum.getInadequateSignatureRateAssessment().add(sheet.getInadequateSignatureRateAssessment()));
                    sheetSum.setAutomaticTicketAssessment(sheetSum.getAutomaticTicketAssessment().add(sheet.getAutomaticTicketAssessment()));
                    sheetSum.setTicketServiceQualityAssessment(sheetSum.getTicketServiceQualityAssessment().add(sheet.getTicketServiceQualityAssessment()));
                    sheetSum.setPhoneServiceQualityAssessment(sheetSum.getPhoneServiceQualityAssessment().add(sheet.getPhoneServiceQualityAssessment()));
                    sheetSum.setPeersPackagingAssessment(sheetSum.getPeersPackagingAssessment().add(sheet.getPeersPackagingAssessment()));
                    sheetSum.setBranchViolationsAssessment(sheetSum.getBranchViolationsAssessment().add(sheet.getBranchViolationsAssessment()));
                    sheetSum.setTerminalAssessment(sheetSum.getTerminalAssessment().add(sheet.getTerminalAssessment()));
                    sheetSum.setNetworkManagementComprehensiveCharge(sheetSum.getNetworkManagementComprehensiveCharge().add(sheet.getNetworkManagementComprehensiveCharge()));
                    sheetSum.setNetworkManagementComprehensivePayment(sheetSum.getNetworkManagementComprehensivePayment().add(sheet.getNetworkManagementComprehensivePayment()));
                    sheetSum.setVehicleAssessment(sheetSum.getVehicleAssessment().add(sheet.getVehicleAssessment()));
                    sheetSum.setEnvironmentallyFriendlyBagOvertimeCharge(sheetSum.getEnvironmentallyFriendlyBagOvertimeCharge().add(sheet.getEnvironmentallyFriendlyBagOvertimeCharge()));
                    sheetSum.setHeadquartersMajorCustomers(sheetSum.getHeadquartersMajorCustomers().add(sheet.getHeadquartersMajorCustomers()));
                    sheetSum.setScatteredBusinessSettlement(sheetSum.getScatteredBusinessSettlement().add(sheet.getScatteredBusinessSettlement()));
                    sheetSum.setScatteredSinglePerformanceAssessment(sheetSum.getScatteredSinglePerformanceAssessment().add(sheet.getScatteredSinglePerformanceAssessment()));
                    sheetSum.setMarketCustomerServiceCharge(sheetSum.getMarketCustomerServiceCharge().add(sheet.getMarketCustomerServiceCharge()));
                    sheetSum.setCodbusiness(sheetSum.getCodbusiness().add(sheet.getCodbusiness()));
                    sheetSum.setCodpayment(sheetSum.getCodpayment().add(sheet.getCodpayment()));
                    sheetSum.setCodpaymentFee(sheetSum.getCodpaymentFee().add(sheet.getCodpaymentFee()));
                    sheetSum.setInternationalBusinessFee(sheetSum.getInternationalBusinessFee().add(sheet.getInternationalBusinessFee()));
                    sheetSum.setTikTokProject(sheetSum.getTikTokProject().add(sheet.getTikTokProject()));
                    sheetSum.setInsuranceFee(sheetSum.getInsuranceFee().add(sheet.getInsuranceFee()));
                    sheetSum.setHostingServiceFee(sheetSum.getHostingServiceFee().add(sheet.getHostingServiceFee()));
                    sheetSum.setOnlineCustomerServiceFee(sheetSum.getOnlineCustomerServiceFee().add(sheet.getOnlineCustomerServiceFee()));
                    sheetSum.setCallSystemMonthlyRent(sheetSum.getCallSystemMonthlyRent().add(sheet.getCallSystemMonthlyRent()));
                    sheetSum.setPhoneAnsweringServiceFee(sheetSum.getPhoneAnsweringServiceFee().add(sheet.getPhoneAnsweringServiceFee()));
                    sheetSum.setSmsreminderBusiness(sheetSum.getSmsreminderBusiness().add(sheet.getSmsreminderBusiness()));
                    sheetSum.setPhoneCommunicationFee(sheetSum.getPhoneCommunicationFee().add(sheet.getPhoneCommunicationFee()));
                    sheetSum.setHandlingFee(sheetSum.getHandlingFee().add(sheet.getHandlingFee()));
                    sheetSum.setWovenBagFee(sheetSum.getWovenBagFee().add(sheet.getWovenBagFee()));
                    sheetSum.setBranchUtilitiesFee(sheetSum.getBranchUtilitiesFee().add(sheet.getBranchUtilitiesFee()));

                }

                Map<String, ScQualityControlFeeSheet> setMap = collectSet.stream().collect(Collectors.toMap(a -> a.getName(), a -> a));
                //将落实的明细添加到对应的数据上
                for (ScQualityControlFeeSheet sheet : collect) {

                    ScQualityControlFeeSheet sheetSet = setMap.get(sheet.getName());
                    //判断该承包区是否存在调整数据
                    if (sheetSet != null) {

                        sheet.setInboundTickets(sheet.getInboundTickets() + sheetSet.getInboundTickets());
                        sheet.setOutboundTickets(sheet.getOutboundTickets() + sheetSet.getOutboundTickets());
                        sheet.setOutboundThreePiecesDelay(sheet.getOutboundThreePiecesDelay().add(sheetSet.getOutboundThreePiecesDelay()));

                        sheet.setOutboundThreePiecesLost(sheet.getOutboundThreePiecesLost().add(sheetSet.getOutboundThreePiecesLost()));
                        sheet.setOutboundThreePiecesDamaged(sheet.getOutboundThreePiecesDamaged().add(sheetSet.getOutboundThreePiecesDamaged()));
                        sheet.setOutboundThreeReturnMoney(sheet.getOutboundThreeReturnMoney().add(sheetSet.getOutboundThreeReturnMoney()));
                        sheet.setOutboundThreePiecesTotal(sheet.getOutboundThreePiecesTotal().add(sheetSet.getOutboundThreePiecesTotal()));
                        sheet.setOutboundThreePiecesSingleReceipt(sheet.getOutboundThreePiecesSingleReceipt().add(sheetSet.getOutboundThreePiecesSingleReceipt()));
                        sheet.setToContractAreaDelay(sheet.getToContractAreaDelay().add(sheetSet.getToContractAreaDelay()));
                        sheet.setToContractAreaLost(sheet.getToContractAreaLost().add(sheetSet.getToContractAreaLost()));
                        sheet.setToContractAreaDamaged(sheet.getToContractAreaDamaged().add(sheetSet.getToContractAreaDamaged()));
                        sheet.setToContractAreaThreeReturnMoney(sheet.getToContractAreaThreeReturnMoney().add(sheetSet.getToContractAreaThreeReturnMoney()));
                        sheet.setToContractAreaTotal(sheet.getToContractAreaTotal().add(sheetSet.getToContractAreaTotal()));
                        sheet.setToContractAreaSingleReceipt(sheet.getToContractAreaSingleReceipt().add(sheetSet.getToContractAreaSingleReceipt()));
                        sheet.setToContractAreaProfitLoss(sheet.getToContractAreaProfitLoss().add(sheetSet.getToContractAreaProfitLoss()));
                        sheet.setInboundThreePiecesPenaltyDelay(sheet.getInboundThreePiecesPenaltyDelay().add(sheetSet.getInboundThreePiecesPenaltyDelay()));
                        sheet.setInboundThreePiecesPenaltyLost(sheet.getInboundThreePiecesPenaltyLost().add(sheetSet.getInboundThreePiecesPenaltyLost()));
                        sheet.setInboundThreePiecesPenaltyDamaged(sheet.getInboundThreePiecesPenaltyDamaged().add(sheetSet.getInboundThreePiecesPenaltyDamaged()));
                        sheet.setInboundThreePiecesPenaltyOverDispatchFee(sheet.getInboundThreePiecesPenaltyOverDispatchFee().add(sheetSet.getInboundThreePiecesPenaltyOverDispatchFee()));
                        sheet.setInboundThreePiecesThreeIndemnity(sheet.getInboundThreePiecesThreeIndemnity().add(sheetSet.getInboundThreePiecesThreeIndemnity()));
                        sheet.setInboundThreePiecesPenaltyTotal(sheet.getInboundThreePiecesPenaltyTotal().add(sheetSet.getInboundThreePiecesPenaltyTotal()));
                        sheet.setInboundThreePiecesPenaltyFinePerTicket(sheet.getInboundThreePiecesPenaltyFinePerTicket().add(sheetSet.getInboundThreePiecesPenaltyFinePerTicket()));
                        sheet.setPenaltyToContractAreaDelay(sheet.getPenaltyToContractAreaDelay().add(sheetSet.getPenaltyToContractAreaDelay()));
                        sheet.setPenaltyToContractAreaLost(sheet.getPenaltyToContractAreaLost().add(sheetSet.getPenaltyToContractAreaLost()));
                        sheet.setPenaltyToContractAreaDamaged(sheet.getPenaltyToContractAreaDamaged().add(sheetSet.getPenaltyToContractAreaDamaged()));
                        sheet.setPenaltyToContractAreaOverDispatchFee(sheet.getPenaltyToContractAreaOverDispatchFee().add(sheetSet.getPenaltyToContractAreaOverDispatchFee()));
                        sheet.setPenaltyToContractAreaThreeIndemnity(sheet.getPenaltyToContractAreaThreeIndemnity().add(sheetSet.getPenaltyToContractAreaThreeIndemnity()));
                        sheet.setPenaltyToContractAreaTotal(sheet.getPenaltyToContractAreaTotal().add(sheetSet.getPenaltyToContractAreaTotal()));
                        sheet.setPenaltyToContractAreaFinePerTicket(sheet.getPenaltyToContractAreaFinePerTicket().add(sheetSet.getPenaltyToContractAreaFinePerTicket()));
                        sheet.setThreeIndemnity(sheet.getThreeIndemnity().add(sheetSet.getThreeIndemnity()));
                        sheet.setPriorClaim(sheet.getPriorClaim().add(sheet.getPriorClaim()));
                        sheet.setFalseIssueAssessment(sheet.getFalseIssueAssessment().add(sheetSet.getFalseIssueAssessment()));
                        sheet.setFalseSignatureAssessment(sheet.getFalseSignatureAssessment().add(sheetSet.getFalseSignatureAssessment()));
                        sheet.setInadequateSignatureRateAssessment(sheet.getInadequateSignatureRateAssessment().add(sheetSet.getInadequateSignatureRateAssessment()));
                        sheet.setAutomaticTicketAssessment(sheet.getAutomaticTicketAssessment().add(sheetSet.getAutomaticTicketAssessment()));
                        sheet.setTicketServiceQualityAssessment(sheet.getTicketServiceQualityAssessment().add(sheetSet.getTicketServiceQualityAssessment()));
                        sheet.setPhoneServiceQualityAssessment(sheet.getPhoneServiceQualityAssessment().add(sheetSet.getPhoneServiceQualityAssessment()));
                        sheet.setPeersPackagingAssessment(sheet.getPeersPackagingAssessment().add(sheetSet.getPeersPackagingAssessment()));
                        sheet.setBranchViolationsAssessment(sheet.getBranchViolationsAssessment().add(sheetSet.getBranchViolationsAssessment()));
                        sheet.setTerminalAssessment(sheet.getTerminalAssessment().add(sheetSet.getTerminalAssessment()));
                        sheet.setNetworkManagementComprehensiveCharge(sheet.getNetworkManagementComprehensiveCharge().add(sheetSet.getNetworkManagementComprehensiveCharge()));
                        sheet.setNetworkManagementComprehensivePayment(sheet.getNetworkManagementComprehensivePayment().add(sheetSet.getNetworkManagementComprehensivePayment()));
                        sheet.setVehicleAssessment(sheet.getVehicleAssessment().add(sheetSet.getVehicleAssessment()));
                        sheet.setEnvironmentallyFriendlyBagOvertimeCharge(sheet.getEnvironmentallyFriendlyBagOvertimeCharge().add(sheetSet.getEnvironmentallyFriendlyBagOvertimeCharge()));
                        sheet.setHeadquartersMajorCustomers(sheet.getHeadquartersMajorCustomers().add(sheetSet.getHeadquartersMajorCustomers()));
                        sheet.setScatteredBusinessSettlement(sheet.getScatteredBusinessSettlement().add(sheetSet.getScatteredBusinessSettlement()));
                        sheet.setScatteredSinglePerformanceAssessment(sheet.getScatteredSinglePerformanceAssessment().add(sheetSet.getScatteredSinglePerformanceAssessment()));
                        sheet.setMarketCustomerServiceCharge(sheet.getMarketCustomerServiceCharge().add(sheetSet.getMarketCustomerServiceCharge()));
                        sheet.setCodbusiness(sheet.getCodbusiness().add(sheetSet.getCodbusiness()));
                        sheet.setCodpayment(sheet.getCodpayment().add(sheetSet.getCodpayment()));
                        sheet.setCodpaymentFee(sheet.getCodpaymentFee().add(sheetSet.getCodpaymentFee()));
                        sheet.setInternationalBusinessFee(sheet.getInternationalBusinessFee().add(sheetSet.getInternationalBusinessFee()));
                        sheet.setTikTokProject(sheet.getTikTokProject().add(sheetSet.getTikTokProject()));
                        sheet.setInsuranceFee(sheet.getInsuranceFee().add(sheetSet.getInsuranceFee()));
                        sheet.setHostingServiceFee(sheet.getHostingServiceFee().add(sheetSet.getHostingServiceFee()));
                        sheet.setOnlineCustomerServiceFee(sheet.getOnlineCustomerServiceFee().add(sheetSet.getOnlineCustomerServiceFee()));
                        sheet.setCallSystemMonthlyRent(sheet.getCallSystemMonthlyRent().add(sheetSet.getCallSystemMonthlyRent()));
                        sheet.setPhoneAnsweringServiceFee(sheet.getPhoneAnsweringServiceFee().add(sheetSet.getPhoneAnsweringServiceFee()));
                        sheet.setSmsreminderBusiness(sheet.getSmsreminderBusiness().add(sheetSet.getSmsreminderBusiness()));
                        sheet.setPhoneCommunicationFee(sheet.getPhoneCommunicationFee().add(sheetSet.getPhoneCommunicationFee()));
                        sheet.setHandlingFee(sheet.getHandlingFee().add(sheetSet.getHandlingFee()));
                        sheet.setWovenBagFee(sheet.getWovenBagFee().add(sheetSet.getWovenBagFee()));
                        sheet.setBranchUtilitiesFee(sheet.getBranchUtilitiesFee().add(sheetSet.getBranchUtilitiesFee()));
                    }

                    if (sheet.getName().equals("辽宁盘锦公司")) {
                        sheet.setInboundTickets(sheet.getInboundTickets() - sheetSum.getInboundTickets());
                        sheet.setOutboundTickets(sheet.getOutboundTickets() - sheetSum.getOutboundTickets());
                        sheet.setOutboundThreePiecesDelay(sheet.getOutboundThreePiecesDelay().subtract(sheetSum.getOutboundThreePiecesDelay()));

                        sheet.setOutboundThreePiecesLost(sheet.getOutboundThreePiecesLost().subtract(sheetSum.getOutboundThreePiecesLost()));
                        sheet.setOutboundThreePiecesDamaged(sheet.getOutboundThreePiecesDamaged().subtract(sheetSum.getOutboundThreePiecesDamaged()));
                        sheet.setOutboundThreeReturnMoney(sheet.getOutboundThreeReturnMoney().subtract(sheetSum.getOutboundThreeReturnMoney()));
                        sheet.setOutboundThreePiecesTotal(sheet.getOutboundThreePiecesTotal().subtract(sheetSum.getOutboundThreePiecesTotal()));
                        sheet.setOutboundThreePiecesSingleReceipt(sheet.getOutboundThreePiecesSingleReceipt().subtract(sheetSum.getOutboundThreePiecesSingleReceipt()));
                        sheet.setToContractAreaDelay(sheet.getToContractAreaDelay().subtract(sheetSum.getToContractAreaDelay()));
                        sheet.setToContractAreaLost(sheet.getToContractAreaLost().subtract(sheetSum.getToContractAreaLost()));
                        sheet.setToContractAreaDamaged(sheet.getToContractAreaDamaged().subtract(sheetSum.getToContractAreaDamaged()));
                        sheet.setToContractAreaThreeReturnMoney(sheet.getToContractAreaThreeReturnMoney().subtract(sheetSum.getToContractAreaThreeReturnMoney()));
                        sheet.setToContractAreaTotal(sheet.getToContractAreaTotal().subtract(sheetSum.getToContractAreaTotal()));
                        sheet.setToContractAreaSingleReceipt(sheet.getToContractAreaSingleReceipt().subtract(sheetSum.getToContractAreaSingleReceipt()));
                        sheet.setToContractAreaProfitLoss(sheet.getToContractAreaProfitLoss().subtract(sheetSum.getToContractAreaProfitLoss()));
                        sheet.setInboundThreePiecesPenaltyDelay(sheet.getInboundThreePiecesPenaltyDelay().subtract(sheetSum.getInboundThreePiecesPenaltyDelay()));
                        sheet.setInboundThreePiecesPenaltyLost(sheet.getInboundThreePiecesPenaltyLost().subtract(sheetSum.getInboundThreePiecesPenaltyLost()));
                        sheet.setInboundThreePiecesPenaltyDamaged(sheet.getInboundThreePiecesPenaltyDamaged().subtract(sheetSum.getInboundThreePiecesPenaltyDamaged()));
                        sheet.setInboundThreePiecesPenaltyOverDispatchFee(sheet.getInboundThreePiecesPenaltyOverDispatchFee().subtract(sheetSum.getInboundThreePiecesPenaltyOverDispatchFee()));
                        sheet.setInboundThreePiecesThreeIndemnity(sheet.getInboundThreePiecesThreeIndemnity().subtract(sheetSum.getInboundThreePiecesThreeIndemnity()));
                        sheet.setInboundThreePiecesPenaltyTotal(sheet.getInboundThreePiecesPenaltyTotal().subtract(sheetSum.getInboundThreePiecesPenaltyTotal()));
                        sheet.setInboundThreePiecesPenaltyFinePerTicket(sheet.getInboundThreePiecesPenaltyFinePerTicket().subtract(sheetSum.getInboundThreePiecesPenaltyFinePerTicket()));
                        sheet.setPenaltyToContractAreaDelay(sheet.getPenaltyToContractAreaDelay().subtract(sheetSum.getPenaltyToContractAreaDelay()));
                        sheet.setPenaltyToContractAreaLost(sheet.getPenaltyToContractAreaLost().subtract(sheetSum.getPenaltyToContractAreaLost()));
                        sheet.setPenaltyToContractAreaDamaged(sheet.getPenaltyToContractAreaDamaged().subtract(sheetSum.getPenaltyToContractAreaDamaged()));
                        sheet.setPenaltyToContractAreaOverDispatchFee(sheet.getPenaltyToContractAreaOverDispatchFee().subtract(sheetSum.getPenaltyToContractAreaOverDispatchFee()));
                        sheet.setPenaltyToContractAreaThreeIndemnity(sheet.getPenaltyToContractAreaThreeIndemnity().subtract(sheetSum.getPenaltyToContractAreaThreeIndemnity()));
                        sheet.setPenaltyToContractAreaTotal(sheet.getPenaltyToContractAreaTotal().subtract(sheetSum.getPenaltyToContractAreaTotal()));
                        sheet.setPenaltyToContractAreaFinePerTicket(sheet.getPenaltyToContractAreaFinePerTicket().subtract(sheetSum.getPenaltyToContractAreaFinePerTicket()));
                        sheet.setThreeIndemnity(sheet.getThreeIndemnity().subtract(sheetSum.getThreeIndemnity()));
                        sheet.setPriorClaim(sheet.getPriorClaim().add(sheet.getPriorClaim()));
                        sheet.setFalseIssueAssessment(sheet.getFalseIssueAssessment().subtract(sheetSum.getFalseIssueAssessment()));
                        sheet.setFalseSignatureAssessment(sheet.getFalseSignatureAssessment().subtract(sheetSum.getFalseSignatureAssessment()));
                        sheet.setInadequateSignatureRateAssessment(sheet.getInadequateSignatureRateAssessment().subtract(sheetSum.getInadequateSignatureRateAssessment()));
                        sheet.setAutomaticTicketAssessment(sheet.getAutomaticTicketAssessment().subtract(sheetSum.getAutomaticTicketAssessment()));
                        sheet.setTicketServiceQualityAssessment(sheet.getTicketServiceQualityAssessment().subtract(sheetSum.getTicketServiceQualityAssessment()));
                        sheet.setPhoneServiceQualityAssessment(sheet.getPhoneServiceQualityAssessment().subtract(sheetSum.getPhoneServiceQualityAssessment()));
                        sheet.setPeersPackagingAssessment(sheet.getPeersPackagingAssessment().subtract(sheetSum.getPeersPackagingAssessment()));
                        sheet.setBranchViolationsAssessment(sheet.getBranchViolationsAssessment().subtract(sheetSum.getBranchViolationsAssessment()));
                        sheet.setTerminalAssessment(sheet.getTerminalAssessment().subtract(sheetSum.getTerminalAssessment()));
                        sheet.setNetworkManagementComprehensiveCharge(sheet.getNetworkManagementComprehensiveCharge().subtract(sheetSum.getNetworkManagementComprehensiveCharge()));
                        sheet.setNetworkManagementComprehensivePayment(sheet.getNetworkManagementComprehensivePayment().subtract(sheetSum.getNetworkManagementComprehensivePayment()));
                        sheet.setVehicleAssessment(sheet.getVehicleAssessment().subtract(sheetSum.getVehicleAssessment()));
                        sheet.setEnvironmentallyFriendlyBagOvertimeCharge(sheet.getEnvironmentallyFriendlyBagOvertimeCharge().subtract(sheetSum.getEnvironmentallyFriendlyBagOvertimeCharge()));
                        sheet.setHeadquartersMajorCustomers(sheet.getHeadquartersMajorCustomers().subtract(sheetSum.getHeadquartersMajorCustomers()));
                        sheet.setScatteredBusinessSettlement(sheet.getScatteredBusinessSettlement().subtract(sheetSum.getScatteredBusinessSettlement()));
                        sheet.setScatteredSinglePerformanceAssessment(sheet.getScatteredSinglePerformanceAssessment().subtract(sheetSum.getScatteredSinglePerformanceAssessment()));
                        sheet.setMarketCustomerServiceCharge(sheet.getMarketCustomerServiceCharge().subtract(sheetSum.getMarketCustomerServiceCharge()));
                        sheet.setCodbusiness(sheet.getCodbusiness().subtract(sheetSum.getCodbusiness()));
                        sheet.setCodpayment(sheet.getCodpayment().subtract(sheetSum.getCodpayment()));
                        sheet.setCodpaymentFee(sheet.getCodpaymentFee().subtract(sheetSum.getCodpaymentFee()));
                        sheet.setInternationalBusinessFee(sheet.getInternationalBusinessFee().subtract(sheetSum.getInternationalBusinessFee()));
                        sheet.setTikTokProject(sheet.getTikTokProject().subtract(sheetSum.getTikTokProject()));
                        sheet.setInsuranceFee(sheet.getInsuranceFee().subtract(sheetSum.getInsuranceFee()));
                        sheet.setHostingServiceFee(sheet.getHostingServiceFee().subtract(sheetSum.getHostingServiceFee()));
                        sheet.setOnlineCustomerServiceFee(sheet.getOnlineCustomerServiceFee().subtract(sheetSum.getOnlineCustomerServiceFee()));
                        sheet.setCallSystemMonthlyRent(sheet.getCallSystemMonthlyRent().subtract(sheetSum.getCallSystemMonthlyRent()));
                        sheet.setPhoneAnsweringServiceFee(sheet.getPhoneAnsweringServiceFee().subtract(sheetSum.getPhoneAnsweringServiceFee()));
                        sheet.setSmsreminderBusiness(sheet.getSmsreminderBusiness().subtract(sheetSum.getSmsreminderBusiness()));
                        sheet.setPhoneCommunicationFee(sheet.getPhoneCommunicationFee().subtract(sheetSum.getPhoneCommunicationFee()));
                        sheet.setHandlingFee(sheet.getHandlingFee().subtract(sheetSum.getHandlingFee()));
                        sheet.setWovenBagFee(sheet.getWovenBagFee().subtract(sheetSum.getWovenBagFee()));
                        sheet.setBranchUtilitiesFee(sheet.getBranchUtilitiesFee().subtract(sheetSum.getBranchUtilitiesFee()));
                    }
                }
            } else {
                //原始数据查询
                collect = scQualityControlFeeSheetMapper.collect(vo);
            }
        }
        for (ScQualityControlFeeSheet sheet : collect) {
            if (sheet.getOutboundThreePiecesTotal() == null) {
                sheet.setOutboundThreePiecesTotal(BigDecimal.valueOf(0.00));
            }
            if (sheet.getToContractAreaTotal() == null) {
                sheet.setToContractAreaTotal(BigDecimal.valueOf(0.00));
            }
            if (sheet.getInboundThreePiecesPenaltyTotal() == null) {
                sheet.setInboundThreePiecesPenaltyTotal(BigDecimal.valueOf(0.00));
            }
            if (sheet.getPenaltyToContractAreaTotal() == null) {
                sheet.setPenaltyToContractAreaTotal(BigDecimal.valueOf(0.00));
            }
            sheet.setCollectDate(vo.getStartTime() + "至" + vo.getEndTime());
            sheet.setToContractAreaDelay(sheet.getOutboundThreePiecesDelay());
            sheet.setToContractAreaLost(sheet.getOutboundThreePiecesLost());
            sheet.setToContractAreaDamaged(sheet.getOutboundThreePiecesDamaged());
            sheet.setToContractAreaThreeReturnMoney(sheet.getOutboundThreeReturnMoney());
            sheet.setToContractAreaTotal(sheet.getOutboundThreePiecesTotal());
            sheet.setToContractAreaSingleReceipt(sheet.getOutboundThreePiecesSingleReceipt());
            sheet.setToContractAreaProfitLoss(sheet.getOutboundThreePiecesTotal().subtract(sheet.getToContractAreaTotal()));

            sheet.setPenaltyToContractAreaDelay(sheet.getInboundThreePiecesPenaltyDelay());
            sheet.setPenaltyToContractAreaLost(sheet.getInboundThreePiecesPenaltyLost());
            sheet.setPenaltyToContractAreaDamaged(sheet.getInboundThreePiecesPenaltyDamaged());
            sheet.setPenaltyToContractAreaOverDispatchFee(sheet.getInboundThreePiecesPenaltyOverDispatchFee());
            sheet.setPenaltyToContractAreaThreeIndemnity(sheet.getInboundThreePiecesThreeIndemnity());
            sheet.setPenaltyToContractAreaTotal(sheet.getInboundThreePiecesPenaltyTotal());
            sheet.setPenaltyToContractAreaFinePerTicket(sheet.getInboundThreePiecesPenaltyFinePerTicket());
            sheet.setThreeIndemnity(sheet.getInboundThreePiecesPenaltyTotal().subtract(sheet.getPenaltyToContractAreaTotal()));
            if (sheet.getChildren() != null) {
                for (ScQualityControlFeeSheet child : sheet.getChildren()) {
                    child.setToContractAreaDelay(child.getOutboundThreePiecesDelay());
                    child.setToContractAreaLost(child.getOutboundThreePiecesLost());
                    child.setToContractAreaDamaged(child.getOutboundThreePiecesDamaged());
                    child.setToContractAreaThreeReturnMoney(child.getOutboundThreeReturnMoney());
                    child.setToContractAreaTotal(child.getOutboundThreePiecesTotal());
                    child.setToContractAreaSingleReceipt(child.getOutboundThreePiecesSingleReceipt());
                    child.setToContractAreaProfitLoss(child.getOutboundThreePiecesTotal().subtract(child.getToContractAreaTotal()));

                    child.setPenaltyToContractAreaDelay(child.getInboundThreePiecesPenaltyDelay());
                    child.setPenaltyToContractAreaLost(child.getInboundThreePiecesPenaltyLost());
                    child.setPenaltyToContractAreaDamaged(child.getInboundThreePiecesPenaltyDamaged());
                    child.setPenaltyToContractAreaOverDispatchFee(child.getInboundThreePiecesPenaltyOverDispatchFee());
                    child.setPenaltyToContractAreaThreeIndemnity(child.getInboundThreePiecesThreeIndemnity());
                    child.setPenaltyToContractAreaTotal(child.getInboundThreePiecesPenaltyTotal());
                    child.setPenaltyToContractAreaFinePerTicket(child.getInboundThreePiecesPenaltyFinePerTicket());
                    child.setThreeIndemnity(child.getInboundThreePiecesPenaltyTotal().subtract(child.getPenaltyToContractAreaTotal()));
                }
            }
            if (vo.getNetworkLevel() == 1 || vo.getNetworkLevel() == 2){
                vo.setNetworkLevel(1);
                PageDate pageDate = vo.getPageDate();
                pageDate.setPageSize(1000);
                List<ScQualityControlFeeSheet> scQualityControlFeeSheets = scQualityControlFeeSheetCacheMapper.selectScQualityControlFeeSheet(vo);
                vo.setNetworkLevel(0);
                List<ScQualityControlFeeSheet> networkList = scQualityControlFeeSheetCacheMapper.selectScQualityControlFeeSheet(vo);
                systemServiceCharge = new BigDecimal(0);
                wovenBagsCharge = new BigDecimal(0);
                for (ScQualityControlFeeSheet scQualityControlFeeSheet : networkList) {
//                    scQualityControlFeeSheet
                    systemServiceCharge = scQualityControlFeeSheet.getSystemServiceCharge();
                    wovenBagsCharge = scQualityControlFeeSheet.getWovenBagsCharge();
                }
                int tickets = 0;

                for (ScQualityControlFeeSheet scQualityControlFeeSheet : scQualityControlFeeSheets) {
                    if (!scQualityControlFeeSheet.getName().equals("辽宁盘锦公司")) {
                        tickets += scQualityControlFeeSheet.getInboundTickets() + scQualityControlFeeSheet.getOutboundTickets();
                    }
                }
                if (tickets != 0) {
                    BigDecimal divide = systemServiceCharge.divide(new BigDecimal(tickets), new MathContext(5, RoundingMode.HALF_UP));
                    BigDecimal divided = wovenBagsCharge.divide(new BigDecimal(tickets), new MathContext(5, RoundingMode.HALF_UP));
                    for (ScQualityControlFeeSheet scQualityControlFeeSheet : collect) {
                        scQualityControlFeeSheet.setSystemServiceCharge(new BigDecimal(0));
                        scQualityControlFeeSheet.setWovenBagsCharge(new BigDecimal(0));
                        for (ScQualityControlFeeSheet qualityControlFeeSheet : scQualityControlFeeSheets) {
                            if (scQualityControlFeeSheet.getName().equals(qualityControlFeeSheet.getName())){
                                if (scQualityControlFeeSheet.getName().equals("辽宁盘锦公司")) {
                                    scQualityControlFeeSheet.setSystemServiceCharge(new BigDecimal(0));
                                    scQualityControlFeeSheet.setWovenBagsCharge(new BigDecimal(0));
                                } else {
                                    int sheetTickets = scQualityControlFeeSheet.getInboundTickets() + scQualityControlFeeSheet.getOutboundTickets();
                                    scQualityControlFeeSheet.setSystemServiceCharge(divide.multiply(new BigDecimal(sheetTickets)).setScale(3,RoundingMode.HALF_UP));
                                    scQualityControlFeeSheet.setWovenBagsCharge(divided.multiply(new BigDecimal(sheetTickets)).setScale(3,RoundingMode.HALF_UP));
                                }
                            }
                        }

                    }
                }
            }
        }
        return collect;
    }

    @Override
    public ScQualityControlDisposition search(ScQualityControlDispositionVo vo) {
        return scQualityControlDispositionMapper.search(vo);
    }

    @Override
    public boolean update(ScQualityControlDisposition disposition) {
        return scQualityControlDispositionMapper.update(disposition);
    }

    @Override
    public List<ScQualityControlDisposition> selectAll() {
        return scQualityControlDispositionMapper.selectAll();
    }

    @Override
    public List<ScQualityControlFeeSheet> collectExport(ScQualityControlFeeSheetVo vo, OutputStream outputStream) {
        List<ScQualityControlFeeSheet> collect = collectList(vo);
        Workbook workbook = new XSSFWorkbook(); // 创建一个新的Excel工作簿
        Sheet sheet = workbook.createSheet("Amount Data"); // 创建一个新的工作表

        // 创建边框样式
        CellStyle borderStyle = workbook.createCellStyle();
        BorderStyle thin = BorderStyle.THIN;
        short blackColorIndex = IndexedColors.BLACK.getIndex();
        borderStyle.setBorderTop(thin);
        borderStyle.setBorderBottom(thin);
        borderStyle.setBorderLeft(thin);
        borderStyle.setBorderRight(thin);
        borderStyle.setTopBorderColor(blackColorIndex);
        borderStyle.setBottomBorderColor(blackColorIndex);
        borderStyle.setLeftBorderColor(blackColorIndex);
        borderStyle.setRightBorderColor(blackColorIndex);

// 创建表头样式
        CellStyle headerStyle = workbook.createCellStyle();
        Font headerFont = workbook.createFont();
        headerFont.setBold(true);
        headerFont.setFontHeightInPoints((short) 14); // 设置字体大小
        headerStyle.setFont(headerFont);
        headerStyle.setAlignment(HorizontalAlignment.CENTER); // 设置水平居中
        headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中
        headerStyle.setBorderTop(thin);
        headerStyle.setBorderBottom(thin);
        headerStyle.setBorderLeft(thin);
        headerStyle.setBorderRight(thin);
        headerStyle.setTopBorderColor(blackColorIndex);
        headerStyle.setBottomBorderColor(blackColorIndex);
        headerStyle.setLeftBorderColor(blackColorIndex);
        headerStyle.setRightBorderColor(blackColorIndex);

        String[] cellName = {"统计日期", "名称", "进港票数", "出港票数", "出港三件总部给咱-延误", "出港三件总部给咱-遗失", "出港三件总部给咱-破损", "三件申诉返款", "出港三件总部给咱-合计", "出港三件总部给咱-单票返款", "出港理赔公司给承包区-延误", "出港理赔公司给承包区-遗失", "出港理赔公司给承包区-破损", "三件申诉返款", "出港理赔公司给承包区-合计", "出港理赔公司给承包区-单票受款", "出港理赔公司给承包区-三件受款盈亏（盈）", "进港三件理赔公司赔总部-延误", "进港三件理赔公司赔总部-遗失", "进港三件理赔公司赔总部-破损", "进港三件理赔公司赔总部-超派费", "三件申诉赔款", "进港三件理赔公司赔总部-合计", "进港三件理赔公司赔总部-单票罚款", "进港三件理赔承包区赔公司-延误", "进港三件理赔承包区赔公司-遗失", "进港三件理赔承包区赔公司-破损", "进港三件理赔承包区赔公司-超派费", "三件申诉赔款", "进港三件理赔承包区赔公司-合计", "进港三件理赔承包区赔公司-单票罚款", "三件罚款盈亏（亏）", "先行理赔", "虚假问题件考核", "虚假签收考核", "签收率未达标考核", "工单自动考核", "工单服务质量考核", "电话服务质量考核", "同行封装考核", "网点违规行为考核", "末端考核", "网管综合考核收费", "网管综合考核付费", "车辆类考核", "环保袋超时费", "总部大客户", "散件业务结算", "散单履约考核", "市场客服收费", "代收货款业务", "到付业务", "到付业务费用", "国际业务费用", "抖音项目", "保价费", "托管接管服务费", "在线客服服务费", "呼叫系统月租费", "电话接听服务费", "短信提醒业务", "电话通讯费", "手续费", "编织袋费用", "网点水电费", "系统服务费", "编织袋应收", "环保袋使用费", "进港集包应收", "按需派送业务费用", "批货收费"};
        Row headerRow = sheet.createRow(0);
        for (int i = 0; i < cellName.length; i++) {
            Cell cell = headerRow.createCell(i);
            cell.setCellValue(cellName[i]);
            cell.setCellStyle(headerStyle);
        }
        int rowNum = 1; // 行索引从1开始（因为已经有表头行）
        for (ScQualityControlFeeSheet sheet1 : collect) {
            Row dataRow = sheet.createRow(rowNum++);
            // 写入统计日期
            Cell cell = dataRow.createCell(0);
            cell.setCellValue(sheet1.getCollectDate());
            cell.setCellStyle(borderStyle);
            // 写入名称
            Cell cell1 = dataRow.createCell(1);
            cell1.setCellValue(sheet1.getName());
            cell1.setCellStyle(borderStyle);

            // 写入进港/出港票数
            Cell cell2 = dataRow.createCell(2);
            cell2.setCellValue(sheet1.getInboundTickets());
            cell2.setCellStyle(borderStyle);
            Cell cell3 = dataRow.createCell(3);
            cell3.setCellValue(sheet1.getOutboundTickets());
            cell3.setCellStyle(borderStyle);

            // 出港理赔相关字段
            Cell cell4 = dataRow.createCell(4);
            cell4.setCellValue(sheet1.getOutboundThreePiecesDelay().doubleValue());
            cell4.setCellStyle(borderStyle);
            Cell cell5 = dataRow.createCell(5);
            cell5.setCellValue(sheet1.getOutboundThreePiecesLost().doubleValue());
            cell5.setCellStyle(borderStyle);
            Cell cell6 = dataRow.createCell(6);
            cell6.setCellValue(sheet1.getOutboundThreePiecesDamaged().doubleValue());
            cell6.setCellStyle(borderStyle);
            Cell cell7 = dataRow.createCell(7);
            cell7.setCellValue(sheet1.getOutboundThreeReturnMoney().doubleValue());
            cell7.setCellStyle(borderStyle);
            Cell cell8 = dataRow.createCell(8);
            cell8.setCellValue(sheet1.getOutboundThreePiecesTotal().doubleValue());
            cell8.setCellStyle(borderStyle);

            Cell cell9 = dataRow.createCell(9);
            if (sheet1.getOutboundThreePiecesSingleReceipt() != null) {
                cell9.setCellValue(sheet1.getOutboundThreePiecesSingleReceipt().doubleValue());
            }
            cell9.setCellStyle(borderStyle);

            // 出港理赔公司给承包区相关字段

            Cell cell10 = dataRow.createCell(10);
            cell10.setCellValue(sheet1.getToContractAreaDelay().doubleValue());
            cell10.setCellStyle(borderStyle);
            Cell cell11 = dataRow.createCell(11);
            cell11.setCellValue(sheet1.getToContractAreaLost().doubleValue());
            cell11.setCellStyle(borderStyle);
            Cell cell12 = dataRow.createCell(12);
            cell12.setCellValue(sheet1.getToContractAreaDamaged().doubleValue());
            cell12.setCellStyle(borderStyle);
            Cell cell13 = dataRow.createCell(13);
            cell13.setCellValue(sheet1.getToContractAreaThreeReturnMoney().doubleValue());
            cell13.setCellStyle(borderStyle);
            Cell cell14 = dataRow.createCell(14);
            cell14.setCellValue(sheet1.getToContractAreaTotal().doubleValue());
            cell14.setCellStyle(borderStyle);

            Cell cell15 = dataRow.createCell(15);
            cell15.setCellStyle(borderStyle);
            if (sheet1.getToContractAreaSingleReceipt() != null) {
                cell15.setCellValue(sheet1.getToContractAreaSingleReceipt().doubleValue());
            }
            Cell cell16 = dataRow.createCell(16);
            cell16.setCellValue(sheet1.getToContractAreaProfitLoss().doubleValue());
            cell16.setCellStyle(borderStyle);

            // 进港三件理赔相关字段
            Cell cell17 = dataRow.createCell(17);
            cell17.setCellValue(sheet1.getInboundThreePiecesPenaltyDelay().doubleValue());
            cell17.setCellStyle(borderStyle);
            Cell cell18 = dataRow.createCell(18);
            cell18.setCellValue(sheet1.getInboundThreePiecesPenaltyLost().doubleValue());
            cell18.setCellStyle(borderStyle);
            Cell cell19 = dataRow.createCell(19);
            cell19.setCellValue(sheet1.getInboundThreePiecesPenaltyDamaged().doubleValue());
            cell19.setCellStyle(borderStyle);
            Cell cell20 = dataRow.createCell(20);
            cell20.setCellValue(sheet1.getInboundThreePiecesPenaltyOverDispatchFee().doubleValue());
            cell20.setCellStyle(borderStyle);
            Cell cell21 = dataRow.createCell(21);
            cell21.setCellValue(sheet1.getInboundThreePiecesThreeIndemnity().doubleValue());
            cell21.setCellStyle(borderStyle);
            Cell cell22 = dataRow.createCell(22);
            cell22.setCellValue(sheet1.getInboundThreePiecesPenaltyTotal().doubleValue());
            cell22.setCellStyle(borderStyle);
            Cell cell23 = dataRow.createCell(23);
            cell23.setCellValue(sheet1.getInboundThreePiecesPenaltyFinePerTicket() == null ? 0 : sheet1.getInboundThreePiecesPenaltyFinePerTicket().doubleValue());
            cell23.setCellStyle(borderStyle);

            // 进港三件理赔承包区赔公司相关字段
            Cell cell24 = dataRow.createCell(24);
            cell24.setCellValue(sheet1.getPenaltyToContractAreaDelay().doubleValue());
            cell24.setCellStyle(borderStyle);
            Cell cell25 = dataRow.createCell(25);
            cell25.setCellValue(sheet1.getPenaltyToContractAreaLost().doubleValue());
            cell25.setCellStyle(borderStyle);
            Cell cell26 = dataRow.createCell(26);
            cell26.setCellValue(sheet1.getPenaltyToContractAreaDamaged().doubleValue());
            cell26.setCellStyle(borderStyle);
            Cell cell27 = dataRow.createCell(27);
            cell27.setCellValue(sheet1.getPenaltyToContractAreaOverDispatchFee().doubleValue());
            cell27.setCellStyle(borderStyle);
            Cell cell28 = dataRow.createCell(28);
            cell28.setCellValue(sheet1.getPenaltyToContractAreaThreeIndemnity().doubleValue());
            cell28.setCellStyle(borderStyle);
            Cell cell29 = dataRow.createCell(29);
            cell29.setCellValue(sheet1.getPenaltyToContractAreaTotal().doubleValue());
            cell29.setCellStyle(borderStyle);
            Cell cell30 = dataRow.createCell(30);
            cell30.setCellValue(sheet1.getPenaltyToContractAreaFinePerTicket() == null ? 0 : sheet1.getPenaltyToContractAreaFinePerTicket().doubleValue());
            cell30.setCellStyle(borderStyle);
            Cell cell31 = dataRow.createCell(31);
            cell31.setCellValue(sheet1.getThreeIndemnity().doubleValue());
            cell31.setCellStyle(borderStyle);

            // 系统扣款、罚款、赔款相关字段
            Cell cell32 = dataRow.createCell(32);
            cell32.setCellValue(sheet1.getPriorClaim().doubleValue());
            cell32.setCellStyle(borderStyle);
            Cell cell33 = dataRow.createCell(33);
            cell33.setCellValue(sheet1.getFalseIssueAssessment().doubleValue());
            cell33.setCellStyle(borderStyle);
            Cell cell34 = dataRow.createCell(34);
            cell34.setCellValue(sheet1.getFalseSignatureAssessment().doubleValue());
            cell34.setCellStyle(borderStyle);
            Cell cell35 = dataRow.createCell(35);
            cell35.setCellValue(sheet1.getInadequateSignatureRateAssessment().doubleValue());
            cell35.setCellStyle(borderStyle);
            Cell cell36 = dataRow.createCell(36);
            cell36.setCellValue(sheet1.getAutomaticTicketAssessment().doubleValue());
            cell36.setCellStyle(borderStyle);
            Cell cell37 = dataRow.createCell(37);
            cell37.setCellValue(sheet1.getTicketServiceQualityAssessment().doubleValue());
            cell37.setCellStyle(borderStyle);
            Cell cell38 = dataRow.createCell(38);
            cell38.setCellValue(sheet1.getPhoneServiceQualityAssessment().doubleValue());
            cell38.setCellStyle(borderStyle);
            Cell cell39 = dataRow.createCell(39);
            cell39.setCellValue(sheet1.getPeersPackagingAssessment().doubleValue());
            cell39.setCellStyle(borderStyle);
            Cell cell40 = dataRow.createCell(40);
            cell40.setCellValue(sheet1.getBranchViolationsAssessment().doubleValue());
            cell40.setCellStyle(borderStyle);
            Cell cell41 = dataRow.createCell(41);
            cell41.setCellValue(sheet1.getTerminalAssessment().doubleValue());
            cell41.setCellStyle(borderStyle);
            Cell cell42 = dataRow.createCell(42);
            cell42.setCellValue(sheet1.getNetworkManagementComprehensiveCharge().doubleValue());
            cell42.setCellStyle(borderStyle);
            Cell cell43 = dataRow.createCell(43);
            cell43.setCellValue(sheet1.getNetworkManagementComprehensivePayment().doubleValue());
            cell43.setCellStyle(borderStyle);
            Cell cell44 = dataRow.createCell(44);
            cell44.setCellValue(sheet1.getVehicleAssessment().doubleValue());
            cell44.setCellStyle(borderStyle);
            Cell cell45 = dataRow.createCell(45);
            cell45.setCellValue(sheet1.getEnvironmentallyFriendlyBagOvertimeCharge().doubleValue());
            cell45.setCellStyle(borderStyle);

            // 市场部业务相关字段
            Cell cell46 = dataRow.createCell(46);
            cell46.setCellValue(sheet1.getHeadquartersMajorCustomers().doubleValue());
            cell46.setCellStyle(borderStyle);
            Cell cell47 = dataRow.createCell(47);
            cell47.setCellValue(sheet1.getScatteredBusinessSettlement().doubleValue());
            cell47.setCellStyle(borderStyle);
            Cell cell48 = dataRow.createCell(48);
            cell48.setCellValue(sheet1.getScatteredSinglePerformanceAssessment().doubleValue());
            cell48.setCellStyle(borderStyle);
            Cell cell49 = dataRow.createCell(49);
            cell49.setCellValue(sheet1.getMarketCustomerServiceCharge().doubleValue());
            cell49.setCellStyle(borderStyle);
            Cell cell50 = dataRow.createCell(50);
            cell50.setCellValue(sheet1.getCodbusiness().doubleValue());
            cell50.setCellStyle(borderStyle);
            Cell cell51 = dataRow.createCell(51);
            cell51.setCellValue(sheet1.getCodpayment().doubleValue());
            cell51.setCellStyle(borderStyle);
            Cell cell52 = dataRow.createCell(52);
            cell52.setCellValue(sheet1.getCodpaymentFee().doubleValue());
            cell52.setCellStyle(borderStyle);
            Cell cell53 = dataRow.createCell(53);
            cell53.setCellValue(sheet1.getInternationalBusinessFee().doubleValue());
            cell53.setCellStyle(borderStyle);
            Cell cell54 = dataRow.createCell(54);
            cell54.setCellValue(sheet1.getTikTokProject().doubleValue());
            cell54.setCellStyle(borderStyle);
            Cell cell55 = dataRow.createCell(55);
            cell55.setCellValue(sheet1.getInsuranceFee().doubleValue());
            cell55.setCellStyle(borderStyle);

            // 综合费用相关字段
            Cell cell56 = dataRow.createCell(56);
            cell56.setCellValue(sheet1.getHostingServiceFee().doubleValue());
            cell56.setCellStyle(borderStyle);
            Cell cell57 = dataRow.createCell(57);
            cell57.setCellValue(sheet1.getOnlineCustomerServiceFee().doubleValue());
            cell57.setCellStyle(borderStyle);
            Cell cell58 = dataRow.createCell(58);
            cell58.setCellValue(sheet1.getCallSystemMonthlyRent().doubleValue());
            cell58.setCellStyle(borderStyle);
            Cell cell59 = dataRow.createCell(59);
            cell59.setCellValue(sheet1.getPhoneAnsweringServiceFee().doubleValue());
            cell59.setCellStyle(borderStyle);
            Cell cell60 = dataRow.createCell(60);
            cell60.setCellValue(sheet1.getSmsreminderBusiness().doubleValue());
            cell60.setCellStyle(borderStyle);
            Cell cell61 = dataRow.createCell(61);
            cell61.setCellValue(sheet1.getPhoneCommunicationFee().doubleValue());
            cell61.setCellStyle(borderStyle);
            Cell cell62 = dataRow.createCell(62);
            cell62.setCellValue(sheet1.getHandlingFee().doubleValue());
            cell62.setCellStyle(borderStyle);
            Cell cell63 = dataRow.createCell(63);
            cell63.setCellValue(sheet1.getWovenBagFee().doubleValue());
            cell63.setCellStyle(borderStyle);
            Cell cell64 = dataRow.createCell(64);
            cell64.setCellValue(sheet1.getBranchUtilitiesFee().doubleValue());
            cell64.setCellStyle(borderStyle);

            Cell cell65 = dataRow.createCell(65);
            cell65.setCellValue(sheet1.getSystemServiceCharge().doubleValue());
            cell65.setCellStyle(borderStyle);
            Cell cell66 = dataRow.createCell(66);
            cell66.setCellValue(sheet1.getWovenBagsCharge().doubleValue());
            cell66.setCellStyle(borderStyle);
            Cell cell67 = dataRow.createCell(67);
            cell67.setCellValue(sheet1.getReusableBagUsageFee().doubleValue());
            cell67.setCellStyle(borderStyle);
            Cell cell68 = dataRow.createCell(68);
            cell68.setCellValue(sheet1.getInboundPackageReceivable().doubleValue());
            cell68.setCellStyle(borderStyle);
            Cell cell69 = dataRow.createCell(69);
            cell69.setCellValue(sheet1.getDeliveryChargesOnDemand().doubleValue());
            cell69.setCellStyle(borderStyle);
            Cell cell70 = dataRow.createCell(70);
            cell70.setCellValue(sheet1.getLotCharge().doubleValue());
            cell70.setCellStyle(borderStyle);
        }
        try {
            workbook.write(outputStream); // 将工作簿写入输出流
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            workbook.close(); // 关闭工作簿
        } catch (IOException e) {
            e.printStackTrace();
        }
        return collect;
    }

    @Override
    public List<HqNetworkBillDetail> point(ScQualityControlFeeSheetPointVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return hqNetworkBillDetailMapper.scQualityPoint(vo);
    }


    public List<TableVo> getTableVo() {
        List<TableVo> first = new ArrayList<>();
        TableVo firstTableVo = new TableVo();
        firstTableVo.setFields("collectDate");
        firstTableVo.setTranslate("统计日期");
        firstTableVo.setIsPoint(0);
        first.add(firstTableVo);
        firstTableVo = new TableVo();
        firstTableVo.setFields("name");
        firstTableVo.setTranslate("承包区名称");
        first.add(firstTableVo);
        firstTableVo = new TableVo();
        firstTableVo.setFields("inboundTickets");
        firstTableVo.setTranslate("进港票数");
        firstTableVo.setIsPoint(1);
        first.add(firstTableVo);
        firstTableVo = new TableVo();
        firstTableVo.setFields("outboundTickets");
        firstTableVo.setTranslate("出港票数");
        firstTableVo.setIsPoint(2);
        first.add(firstTableVo);

        // "三件返款"部分
        firstTableVo = new TableVo();
        firstTableVo.setFields("threeReturn");
        firstTableVo.setTranslate("三件返款");

        List<TableVo> second = new ArrayList<>();

        TableVo secondTableVo = new TableVo();
        secondTableVo.setFields("headToMe");
        secondTableVo.setTranslate("出港理赔总部给公司");
        List<TableVo> third = new ArrayList<>();
        String[] headToMe = {"outboundThreePiecesDelay", "outboundThreePiecesLost", "outboundThreePiecesDamaged", "outboundThreeReturnMoney", "outboundThreePiecesTotal", "outboundThreePiecesSingleReceipt"};
        InitTableVo initTableVo = new InitTableVo();
        initTableVo.setFields(headToMe);
        initTableVo.setCode("scQuality");
        third = tableService.initTable(initTableVo);
        for (TableVo tableVo : third) {
            String fields = tableVo.getFields();
            switch (fields) {
                case "outboundThreePiecesDelay":
                    tableVo.setIsPoint(3);
                    break;
                case "outboundThreePiecesLost":
                    tableVo.setIsPoint(4);
                    break;
                case "outboundThreePiecesDamaged":
                    tableVo.setIsPoint(5);
                    break;
                case "outboundThreeReturnMoney":
                    tableVo.setIsPoint(6);
                    break;
            }
        }
        secondTableVo.setSunList(third);
        second.add(secondTableVo);

        secondTableVo = new TableVo();
        secondTableVo.setFields("meToArea");
        secondTableVo.setTranslate("出港理赔公司给承包区");
        third = new ArrayList<>();
        String[] meToArea = {"toContractAreaDelay", "toContractAreaLost", "toContractAreaDamaged", "toContractAreaThreeReturnMoney", "toContractAreaTotal", "toContractAreaSingleReceipt", "toContractAreaProfitLoss"};
        initTableVo = new InitTableVo();
        initTableVo.setFields(meToArea);
        initTableVo.setCode("scQuality");
        third = tableService.initTable(initTableVo);
        for (TableVo tableVo : third) {
            String fields = tableVo.getFields();
            switch (fields) {
                case "toContractAreaDelay":
                    tableVo.setIsPoint(7);
                    break;
                case "toContractAreaLost":
                    tableVo.setIsPoint(8);
                    break;
                case "toContractAreaDamaged":
                    tableVo.setIsPoint(9);
                    break;
                case "toContractAreaThreeReturnMoney":
                    tableVo.setIsPoint(10);
                    break;
            }
        }
        secondTableVo.setSunList(third);
        second.add(secondTableVo);

        firstTableVo.setSunList(second);
        first.add(firstTableVo);

        // "三件赔款"部分
        firstTableVo = new TableVo();
        firstTableVo.setFields("threePay");
        firstTableVo.setTranslate("三件赔款");

        second = new ArrayList<>();  // Reset second list for the "三件赔款" section

        secondTableVo = new TableVo();
        secondTableVo.setFields("inboundToHead");
        secondTableVo.setTranslate("进港三件理赔公司赔总部");
        third = new ArrayList<>();
        String[] inboundToHead = {"inboundThreePiecesPenaltyDelay", "inboundThreePiecesPenaltyLost", "inboundThreePiecesPenaltyDamaged", "inboundThreePiecesPenaltyOverDispatchFee", "inboundThreePiecesThreeIndemnity", "inboundThreePiecesPenaltyTotal", "inboundThreePiecesPenaltyFinePerTicket"};
        initTableVo = new InitTableVo();
        initTableVo.setFields(inboundToHead);
        initTableVo.setCode("scQuality");
        third = tableService.initTable(initTableVo);
        for (TableVo tableVo : third) {
            String fields = tableVo.getFields();
            switch (fields) {
                case "inboundThreePiecesPenaltyDelay":
                    tableVo.setIsPoint(11);
                    break;
                case "inboundThreePiecesPenaltyLost":
                    tableVo.setIsPoint(12);
                    break;
                case "inboundThreePiecesPenaltyDamaged":
                    tableVo.setIsPoint(13);
                    break;
                case "inboundThreePiecesPenaltyOverDispatchFee":
                    tableVo.setIsPoint(14);
                    break;
                case "inboundThreePiecesThreeIndemnity":
                    tableVo.setIsPoint(15);
                    break;
            }
        }
        secondTableVo.setSunList(third);
        second.add(secondTableVo);

        secondTableVo = new TableVo();
        secondTableVo.setFields("inboundToMe");
        secondTableVo.setTranslate("进港三件理赔承包区赔公司");
        third = new ArrayList<>();
        String[] inboundToMe = {"penaltyToContractAreaDelay", "penaltyToContractAreaLost", "penaltyToContractAreaDamaged", "penaltyToContractAreaThreeIndemnity", "penaltyToContractAreaTotal", "penaltyToContractAreaFinePerTicket", "threeIndemnity"};
        initTableVo = new InitTableVo();
        initTableVo.setFields(inboundToMe);
        initTableVo.setCode("scQuality");
        third = tableService.initTable(initTableVo);
        for (TableVo tableVo : third) {
            String fields = tableVo.getFields();
            switch (fields) {
                case "penaltyToContractAreaDelay":
                    tableVo.setIsPoint(16);
                    break;
                case "penaltyToContractAreaLost":
                    tableVo.setIsPoint(17);
                    break;
                case "penaltyToContractAreaDamaged":
                    tableVo.setIsPoint(18);
                    break;
                case "penaltyToContractAreaThreeIndemnity":
                    tableVo.setIsPoint(19);
                    break;
            }
        }
        secondTableVo.setSunList(third);
        second.add(secondTableVo);

        firstTableVo.setSunList(second);
        first.add(firstTableVo);

        firstTableVo = new TableVo();
        firstTableVo.setFields("systemDeduction");
        firstTableVo.setTranslate("系统扣款、罚款、赔款");
        second = new ArrayList<>();
        String[] systemDeduction = {"priorClaim", "falseIssueAssessment", "falseSignatureAssessment", "inadequateSignatureRateAssessment", "automaticTicketAssessment", "ticketServiceQualityAssessment", "phoneServiceQualityAssessment", "peersPackagingAssessment", "branchViolationsAssessment", "terminalAssessment", "networkManagementComprehensiveCharge", "networkManagementComprehensivePayment", "vehicleAssessment", "environmentallyFriendlyBagOvertimeCharge"};
        initTableVo = new InitTableVo();
        initTableVo.setFields(systemDeduction);
        initTableVo.setCode("scQuality");
        second = tableService.initTable(initTableVo);
        for (TableVo tableVo : second) {
            String fields = tableVo.getFields();
            switch (fields) {
                case "priorClaim":
                    tableVo.setIsPoint(21);
                    break;
                case "falseIssueAssessment":
                    tableVo.setIsPoint(22);
                    break;
                case "falseSignatureAssessment":
                    tableVo.setIsPoint(23);
                    break;
                case "inadequateSignatureRateAssessment":
                    tableVo.setIsPoint(24);
                    break;
                case "automaticTicketAssessment":
                    tableVo.setIsPoint(25);
                    break;
                case "ticketServiceQualityAssessment":
                    tableVo.setIsPoint(26);
                    break;
                case "phoneServiceQualityAssessment":
                    tableVo.setIsPoint(27);
                    break;
                case "peersPackagingAssessment":
                    tableVo.setIsPoint(28);
                    break;
                case "branchViolationsAssessment":
                    tableVo.setIsPoint(29);
                    break;
                case "terminalAssessment":
                    tableVo.setIsPoint(30);
                    break;
                case "networkManagementComprehensiveCharge":
                    tableVo.setIsPoint(31);
                    break;
                case "networkManagementComprehensivePayment":
                    tableVo.setIsPoint(32);
                    break;
                case "vehicleAssessment":
                    tableVo.setIsPoint(33);
                    break;
                case "environmentallyFriendlyBagOvertimeCharge":
                    tableVo.setIsPoint(34);
                    break;
            }
        }
        firstTableVo.setSunList(second);
        first.add(firstTableVo);

        firstTableVo = new TableVo();
        firstTableVo.setFields("market");
        firstTableVo.setTranslate("市场部业务");
        second = new ArrayList<>();
        String[] market = {"headquartersMajorCustomers", "scatteredBusinessSettlement", "scatteredSinglePerformanceAssessment", "marketCustomerServiceCharge", "codbusiness", "codpayment", "codpaymentFee", "internationalBusinessFee", "tikTokProject", "insuranceFee"};
        initTableVo = new InitTableVo();
        initTableVo.setFields(market);
        initTableVo.setCode("scQuality");
        second = tableService.initTable(initTableVo);
        for (TableVo tableVo : second) {
            String fields = tableVo.getFields();
            switch (fields) {
                case "headquartersMajorCustomers":
                    tableVo.setIsPoint(35);
                    break;
                case "scatteredBusinessSettlement":
                    tableVo.setIsPoint(36);
                    break;
                case "scatteredSinglePerformanceAssessment":
                    tableVo.setIsPoint(37);
                    break;
                case "marketCustomerServiceCharge":
                    tableVo.setIsPoint(38);
                    break;
                case "codbusiness":
                    tableVo.setIsPoint(39);
                    break;
                case "codpayment":
                    tableVo.setIsPoint(40);
                    break;
                case "codpaymentFee":
                    tableVo.setIsPoint(41);
                    break;
                case "internationalBusinessFee":
                    tableVo.setIsPoint(42);
                    break;
                case "tikTokProject":
                    tableVo.setIsPoint(43);
                    break;
                case "insuranceFee":
                    tableVo.setIsPoint(44);
                    break;
            }
        }
        firstTableVo.setSunList(second);
        first.add(firstTableVo);

        firstTableVo = new TableVo();
        firstTableVo.setFields("fee");
        firstTableVo.setTranslate("综合费用");
        second = new ArrayList<>();
        String[] fee = {"hostingServiceFee", "onlineCustomerServiceFee", "callSystemMonthlyRent", "phoneAnsweringServiceFee", "smsreminderBusiness", "phoneCommunicationFee", "handlingFee", "wovenBagFee", "branchUtilitiesFee"
                , "systemServiceCharge", "wovenBagsCharge", "reusableBagUsageFee", "inboundPackageReceivable", "deliveryChargesOnDemand", "lotCharge"};
        initTableVo = new InitTableVo();
        initTableVo.setFields(fee);
        initTableVo.setCode("scQuality");
        second = tableService.initTable(initTableVo);
        for (TableVo tableVo : second) {
            String fields = tableVo.getFields();
            switch (fields) {
                case "hostingServiceFee":
                    tableVo.setIsPoint(45);
                    break;
                case "onlineCustomerServiceFee":
                    tableVo.setIsPoint(46);
                    break;
                case "callSystemMonthlyRent":
                    tableVo.setIsPoint(47);
                    break;
                case "phoneAnsweringServiceFee":
                    tableVo.setIsPoint(48);
                    break;
                case "smsreminderBusiness":
                    tableVo.setIsPoint(49);
                    break;
                case "phoneCommunicationFee":
                    tableVo.setIsPoint(50);
                    break;
                case "handlingFee":
                    tableVo.setIsPoint(51);
                    break;
                case "wovenBagFee":
                    tableVo.setIsPoint(52);
                    break;
                case "branchUtilitiesFee":
                    tableVo.setIsPoint(53);
                    break;
            }
        }
        firstTableVo.setSunList(second);
        first.add(firstTableVo);

        return first;
    }
}
